<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
				var arr = [1,20,300,44]
				
				var arr2 = [1,20,300,44]
				
				var objArr = [
					{name:"xiaoye",age:30},
					{name:"xiaomei",age:20},
					{name:"xiaohei",age:40},
					{name:"xiaolong",age:33},
				]
				
				//排序函数--升序
				function sortNum(a,b){return a-b}
				//排序函数--降序
				function sortNum2(a,b){return b-a}
				
				//调用升序函数--改变原来的数组
				 arr.sort(sortNum)
				console.log("升序",arr);
				
				//调用降序函数--改变原来的数组
				arr2.sort(sortNum2)
				console.log("降序",arr2);
				
				function objSort(str){
				     return function(a,b){return a[str] - b[str]}
				    }
				
				objArr.sort(objSort('age'))
				console.table("ss",objArr)
				
		</script>
	</body>
</html>
